{extend name="Common/common" /}

{block name="style"}
<link rel="stylesheet" href="/static_admin/wangEditor/wangEditor.min.css">
<style>
    .layui-form {
        width: 825px;
    }
    #editor {
        height: 630px !important;
    }
    #editor .w-e-text-container {
        height: 600px !important;
    }
</style>
{/block}

{block name="content"}
<form id="form" class="layui-form" action="{:url('@admin/intro')}" method="post">
    <input type="hidden" name="_method" value="PUT">
    <div class="layui-form-item">
      <label class="layui-form-label">标题：</label>
      <div class="layui-input-block">
        <input type="text" name="title" value="{$intro.title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
      </div>
    </div>
    <!--<div class="layui-form-item">
        <label class="layui-form-label">PDF文件：</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-primary fileinput-button">
                <span>上传</span>
                <input type="hidden" name="down_url"  value="{intro['down_url']}">
                <input type="file" name="file" id="file">
            </button>
        </div>
    </div>-->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容：</label>
        <div class="layui-input-block">
            <input type="hidden" name="content" value="{$intro.content}">
            <div id="editor" placeholder="请输入内容"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="submit" class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="history.back()">返回</button>
        </div>
    </div>
</form>
{/block}

{block name="script"}
<script src="/static_admin/wangEditor/wangEditor.min.js"></script>
<script>
    var E = window.wangEditor;
    var editor = new E('#editor');

    editor.customConfig.uploadImgServer = '{:url("@admin/upload")}';

    editor.create();

    $(function () {

        editor.txt.html($('input[name="content"]').val());


        $('#submit').on('click', function () {
            $('input[name="content"]').val(editor.txt.html())
        })
    });
</script>
{/block}